package org.red_cross_service.service;

import org.red_cross_service.common.response.Response;
import org.red_cross_service.domain.entity.CarouselEntity;
import org.red_cross_service.mapper.CarouselMapper;
import org.red_cross_service.utils.QueryWrapperUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CarouselService {

    @Autowired
    private CarouselMapper carouselMapper;


    public Response getCarouselList(CarouselEntity carouselEntity) {
        return Response.success(carouselMapper.selectList(QueryWrapperUtils.buildQuery(carouselEntity)));
    }
    public Response addCarousel(CarouselEntity carouselEntity) {
        carouselMapper.insert(carouselEntity);
        return Response.success();
    }
    public Response updateCarousel(CarouselEntity carouselEntity) {
        carouselMapper.updateById(carouselEntity);
        return Response.success();
    }
    public Response deleteCarousel(Long id) {
        carouselMapper.deleteById(id);
        return Response.success();
    }

    public Response selectOne(CarouselEntity carouselEntity) {
        return Response.success(carouselMapper.selectById(carouselEntity.getCarouselId()));
    }
}
